package com.haier.bims.demo.controller;

import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.haier.bims.demo.bean.User;
import com.haier.bims.demo.service.IUserService;

@Controller
public class UserController {

	private static final String XML_VIEW_NAME = "user";
	
	private Jaxb2Marshaller jaxb2Mashaller;
	
	private IUserService userService;
	
	public void setJaxb2Mashaller(Jaxb2Marshaller jaxb2Mashaller) {
		this.jaxb2Mashaller = jaxb2Mashaller;
	} 
	
	
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	
	@RequestMapping(method=RequestMethod.GET, value="/user/{id}")
	public ModelAndView getUser(@PathVariable String id) {
		User user = userService.getUserInfo(id);
		return new ModelAndView(XML_VIEW_NAME, "user", user);
	}
}
